<?php
/**
 * Created by PhpStorm.
 * User: cy
 * Date: 18-12-31
 * Time: 下午5:08
 */

namespace app\models\forms;


use app\models\Admin;
use Yii;
use yii\base\Model;

class AdminLoginForm extends Model
{
    private $admin=false;//用户对象


    public function login()
    {
        //登录成功，设置信息
        return Yii::$app->admin->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
    }

    public function getUser()
    {
        if ($this->admin === false) {
            $this->admin = Admin::findByUsername($this->name);
        }

        return $this->admin;
    }

}